{{template "base/base.html" .}}
{{template "base/base_common.html" .}}
{{define "meta"}}<title>{{i18n .Lang "post.post_new"}} - {{i18n .Lang "app_name"}}</title>{{end}}
{{define "body"}}
<div class="row">
    <div id="content" class="col-md-9">
        <div class="box">
            <ol class="breadcrumb">
                <li><a href="{{.AppUrl}}"><span class="glyphicon glyphicon-home"></span></a></li>
                {{if .Topic}}
                <li><a href="{{.Topic.Link}}">{{.Topic.Name}}</a></li>
                <li>{{i18n .Lang "post.post_new"}}</li>
                {{end}}
                {{if .Category}}
                    <li><a href="{{.Category.Link}}">{{.Category.Name}}</a></li>
                    <li>{{i18n .Lang "post.post_new"}}</li>
                {{end}}
            </ol>
            {{if .Topic}}
            <form id="post-new" method="POST" action="{{.AppUrl}}new?topic={{.Topic.Slug}}">
            {{end}}
            {{if .Category}}
            <form id="post-new" method="POST" action="{{.AppUrl}}new?category={{.Category.Slug}}">
            {{end}}
                {{.xsrf_html}}{{.once_html}}

                <div class="form-group clearfix">
                    <div class="row">
                        <div class="col-md-3" style="{{if .Topic}}display:none;{{end}}">
                            {{with .PostFormSets.Fields.Topic}}
                                <div class="post-topics{{if .Error}} has-error{{end}}">
                                    {{call .Field}}
                                </div>
                            {{end}}
                        </div>
                        <div class="{{if .Topic}}col-md-12{{else}}col-md-9{{end}}">
                            {{with .PostFormSets.Fields.Title}}
                            <div class="post-title{{if .Error}} has-error{{end}}">
                                {{call .Field}}
                                {{if .Error}}<p class="error-block">{{.Error}}</p>{{end}}
                                {{if .Help}}<p class="help-block">{{.Help}}</p>{{end}}
                            </div>
                            {{end}}
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="markdown-editor"  data-preview-url="{{$.AppUrl}}api/md" data-savekey="post/new">
                        {{with .PostFormSets.Fields.Content}}
                            {{template "post/component/editor.html" dict "root" $ "Field" .Field "Error" .Error "Help" .Help}}
                        {{end}}
                    </div>
                </div>
                <div class="form-group clearfix">
                    <button type="submit" class="btn btn-primary pull-right">{{i18n .Lang "submit"}} <i class="icon-chevron-sign-right"></i></button>
                </div>
                {{.Error}}
            </form>
        </div>
	</div>
    <div id="sidebar" class="col-md-3">
        <div class="box">
            <div class="box-heading">{{i18n .Lang "new_post_prompt"}}</div>
            <div class="">
                <ul class="sidebar-list">
                    <li>{{i18n .Lang "new_post_prompt_content_1"}}</li>
                    <li>{{i18n .Lang "new_post_prompt_content_2"}}</li>
                    <li>{{i18n .Lang "new_post_prompt_content_3"}}</li>
                </ul>
            </div>
        </div>

        <div class="box">
            <div class="box-heading"><a target="_blank" href="http://daringfireball.net/projects/markdown/syntax">{{i18n .Lang "markdown_syntax_1"}}{{i18n .Lang "help"}}&nbsp;<i class="icon-external-link"></i></a></div>
            <div class="">
                <ul class="sidebar-list">
                    <li>{{i18n .Lang "markdown_syntax_2"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_3"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_4"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_5"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_6"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_7"}}</li>
                    <li>{{i18n .Lang "markdown_syntax_8"}}</li>
                </ul>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
</script>
{{end}}
